package nodeList;

import org.omg.PortableInterceptor.Interceptor;

import java.util.Stack;

/**
 * 用栈实现队列
 * @author le
 */
public class StackToQueue
{
    public static void main(String[] args)
    {
        Stack<Integer> stack = new Stack<>();
        Stack<Integer> s = new Stack<>();

        for (int i = 0; i < 10; i++)
        {
            while(stack.size()!=0 && stack.peek() != null){
                s.push(stack.pop());
            }

            stack.push(i);

            while(s.size()!= 0 && s.peek() != null){
                stack.push(s.pop());
            }
        }

        while(stack.size()!=0 && stack.peek() != null){
            System.out.println(stack.pop());
        }

        System.out.println(min());
    }

    public static Integer min(){
        Stack<Integer> stack = new Stack<>();

        stack.push(100);
        stack.push(67);
        stack.push(12);
        stack.push(7);
        stack.push(16);
        stack.push(6);
        stack.push(10);
        stack.push(76);
        int min = stack.peek();
        while(stack.size() != 0 && stack.peek() != null){
            int cmp = stack.pop();
            min = cmp < min?cmp:min;
        }

        return min;
    }
}
